package cn.kgc.fcm.dsbank.service.impl;

import cn.kgc.fcm.dsbank.dto.ResultDTO;
import cn.kgc.fcm.dsbank.entity.Syslog;
import cn.kgc.fcm.dsbank.mapper.SyslogMapper;
import cn.kgc.fcm.dsbank.service.SyslogService;
import cn.kgc.fcm.dsbank.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class SyslogServiceImpl implements SyslogService {

    @Autowired
    private SyslogMapper syslogMapper;
    @Override
    public ResultDTO<List<Syslog>> selectSyslogByCondition(Syslog syslog, Pager pager) {


        List<Syslog> syslogs = syslogMapper.selectSyslogByCondition(syslog, pager);
        if (CollectionUtils.isEmpty(syslogs)){
            return ResultDTO.buildError();
        }
        return ResultDTO.buildSuccess(syslogs);
    }

    @Override
    public Integer addSyslog(Syslog syslog) {

        return syslogMapper.addSyslog(syslog);
    }
}
